package com.haoan.index.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.haoan.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.haoan.common.annotation.Log;
import com.haoan.common.core.controller.BaseController;
import com.haoan.common.core.domain.AjaxResult;
import com.haoan.common.enums.BusinessType;
import com.haoan.index.domain.TurnOver;
import com.haoan.index.service.TurnOverService;
import com.haoan.common.utils.poi.ExcelUtil;
import com.haoan.common.core.page.TableDataInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 翻转图片Controller
 *
 * @author autoGen
 * @date 2025-01-03
 */
@Api(value="联动图片",tags = "联动图片")
@RestController
@RequestMapping("/index/turnOver")
public class TurnOverController extends BaseController
{
    @Resource
    private TurnOverService turnOverService;

    /**
     * 查询联动图片列表
     */
    @ApiOperation("查询联动图片列表")
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(TurnOver turnOver)
    {
        startPage();
        List<TurnOver> list = turnOverService.selectTurnOverList(turnOver);
        return getDataTable(list);
    }

    /**
     * 导出联动图片列表
     */
    @ApiOperation("导出联动图片列表")
    @PreAuthorize("@ss.hasPermi('index:turnOver:export')")
    @Log(title = "联动图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TurnOver turnOver)
    {
        List<TurnOver> list = turnOverService.selectTurnOverList(turnOver);
        ExcelUtil<TurnOver> util = new ExcelUtil<TurnOver>(TurnOver.class);
        util.exportExcel(response, list, "联动图片数据");
    }

    /**
     * 获取联动图片详细信息
     */
    @ApiOperation("获取联动图片详细信息")
    @PreAuthorize("@ss.hasPermi('index:turnOver:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(turnOverService.selectTurnOverById(id));
    }

    /**
     * 新增联动图片
     */
    @ApiOperation("新增联动图片")
    @PreAuthorize("@ss.hasPermi('index:turnOver:add')")
    @Log(title = "联动图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TurnOver turnOver)
    {
        return toAjax(turnOverService.insertTurnOver(turnOver));
    }

    /**
     * 修改联动图片
     */
    @ApiOperation("修改联动图片")
    @PreAuthorize("@ss.hasPermi('index:turnOver:edit')")
    @Log(title = "联动图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TurnOver turnOver)
    {
        return toAjax(turnOverService.updateTurnOver(turnOver));
    }

    /**
     * 删除联动图片
     */
    @ApiOperation("删除联动图片")
    @PreAuthorize("@ss.hasPermi('index:turnOver:remove')")
    @Log(title = "联动图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(turnOverService.deleteTurnOverByIds(ids));
    }
}
